package com.itheima.nio.tomcat.handler;

import java.nio.channels.SelectionKey;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;

public class AcceptHandler {

    public SocketChannel connectSocketChannel(SelectionKey selectionKey){
        try{
            ServerSocketChannel serverSocketChannel1 = (ServerSocketChannel) selectionKey.channel();
            SocketChannel socketChannel = serverSocketChannel1.accept();
            socketChannel.configureBlocking(false);
            socketChannel.register(selectionKey.selector(), SelectionKey.OP_READ);
            return socketChannel;
        } catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }
}
